<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration
{
    private $table = 'users';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->table, function (Blueprint $table) {
            $table->increments('id');
            $table->string('nickname', 50)->default('')->comment('昵称');
            $table->string('password')->comment('用户密码');
            $table->tinyInteger('gender')->default(0)->comment('性别：0为未知，1为男，2为女');
            $table->string('avatar')->default('')->comment('头像');
            $table->string('api_token', 60)->unique();
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `{$this->table}` COMMENT '用户表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->table);
    }
}
